/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NV_GioiThieuPhimInternalFrame.java
 *
 * Created on 09-04-2012, 20:06:26
 */
package GUI;

import DAO.MySQLDataAccessHelper;
import DAO.PhimDAO;
import POJO.PhimPoJo;
import java.sql.ResultSet;
import javax.swing.DefaultButtonModel;
import javax.swing.DefaultListModel;

/**
 *
 * @author tran quoc thinh
 */
public class NV_GioiThieuPhimInternalFrame extends javax.swing.JInternalFrame {

    /** Creates new form NV_GioiThieuPhimInternalFrame */
    public NV_GioiThieuPhimInternalFrame() {
        initComponents();   
        DefaultListModel list = new DefaultListModel();
        this.jlstPhim.setModel(list);
        try
        {
            ResultSet rs = PhimDAO.DSPhim();
            while(rs.next())
            {
                PhimPoJo ph = new PhimPoJo();
                ph.setMaPhim(rs.getString("MaPhim"));
                ph.setTenPhim(rs.getString("TenPhim"));
                ph.setGioiThieu(rs.getString("GioiThieu"));               
                ph.setTinhtrang(rs.getInt("TinhTrang"));
                list.addElement(ph);                             
            }
            MySQLDataAccessHelper helper = new MySQLDataAccessHelper();
            helper.Close();
        }
        catch(Exception ex)
        {            
        }
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel4 = new javax.swing.JPanel();
        jlbTenPhim4 = new javax.swing.JLabel();
        jlbTenPhim = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtxtGioiThieuPhim = new javax.swing.JTextPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jlstPhim = new javax.swing.JList();

        jPanel4.setBackground(new java.awt.Color(204, 204, 204));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Chi Tiết Phim", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        jlbTenPhim4.setText("Tên Phim: ");

        jlbTenPhim.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jlbTenPhim.setText("jLabel1");
        jlbTenPhim.setAutoscrolls(true);

        jtxtGioiThieuPhim.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jtxtGioiThieuPhim.setAlignmentX(1.0F);
        jtxtGioiThieuPhim.setAlignmentY(1.0F);
        jtxtGioiThieuPhim.setMargin(new java.awt.Insets(7, 7, 7, 7));
        jScrollPane2.setViewportView(jtxtGioiThieuPhim);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 692, Short.MAX_VALUE)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jlbTenPhim4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlbTenPhim, javax.swing.GroupLayout.DEFAULT_SIZE, 636, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlbTenPhim4)
                    .addComponent(jlbTenPhim))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Danh Sách Phim", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jlstPhim.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jlstPhim.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jlstPhimValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jlstPhim);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 692, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jlstPhimValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jlstPhimValueChanged
// TODO add your handling code here:
    PhimPoJo ph = new PhimPoJo();
    ph = (PhimPoJo)this.jlstPhim.getSelectedValue();
    this.jtxtGioiThieuPhim.setText(ph.getGioiThieu());
    this.jlbTenPhim.setText(ph.getTenPhim());
}//GEN-LAST:event_jlstPhimValueChanged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel jlbTenPhim;
    private javax.swing.JLabel jlbTenPhim4;
    private javax.swing.JList jlstPhim;
    private javax.swing.JTextPane jtxtGioiThieuPhim;
    // End of variables declaration//GEN-END:variables
}
